﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace td.Core.DiscoverAddins
{
    public partial class Addins : DevExpress.XtraEditors.XtraUserControl
    {
        List<td.Core.Xml.AutoStartXml> ListAutoStartXml { get; set; }
        List<td.Core.Xml.PadXml> ListPadXml { get; set; }
        List<td.Core.Xml.RuntimeXml> ListRuntimeXml { get; set; }
        List<td.Core.Xml.ToolButtonXml> ListToolButtonXml { get; set; }
        public td.Core.Xml.AddIn addin = td.Core.Xml.AddIn.GetInstance();
        public Addins()
        {
            InitializeComponent();
            LoadInfo();
            ListAutoStartXml = new List<Xml.AutoStartXml>();
            ListPadXml = new List<Xml.PadXml>();
            ListRuntimeXml = new List<Xml.RuntimeXml>();
            ListToolButtonXml = new List<Xml.ToolButtonXml>();
           this.listBoxNav.SelectedIndexChanged += new EventHandler(listBoxNav_SelectedIndexChanged);

        }
        public void LoadInfo()
        {
            this.addin.LoadFromFile(Application.StartupPath + "\\addins.xml");
        }
        /// <summary>
        /// 左侧列表框选项变化事件，则在右边动态改变用户控件展示相应的信息
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void listBoxNav_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (this.listBoxNav.SelectedItem.ToString() == "系统信息")
            {
                this.panelcontent.Controls.Clear();
                RunTimeInfo r = new RunTimeInfo(addin);
                r.Dock = DockStyle.Fill;
                this.panelcontent.Controls.Add(r);
            }
            else if (this.listBoxNav.SelectedItem.ToString() == "运行时库")
            {
                this.panelcontent.Controls.Clear();
                RunTimeLists list = new RunTimeLists(ref addin);
                list.Dock = DockStyle.Fill;
                this.panelcontent.Controls.Add(list);
            }
            else if (this.listBoxNav.SelectedItem.ToString() == "工具按钮")
            {
                this.panelcontent.Controls.Clear();
                ToolButtonsLists list = new ToolButtonsLists(addin);
                list.Dock = DockStyle.Fill;
                this.panelcontent.Controls.Add(list);
            }
            else if (this.listBoxNav.SelectedItem.ToString() == "自动启动")
            {
                this.panelcontent.Controls.Clear();
                AutoRunList list = new AutoRunList(addin);
                list.Dock = DockStyle.Fill;
                this.panelcontent.Controls.Add(list);
            }
            else if (this.listBoxNav.SelectedItem.ToString() == "Pad面板")
            {
                this.panelcontent.Controls.Clear();
                PadList list = new PadList(addin);
                list.Dock = DockStyle.Fill;
                this.panelcontent.Controls.Add(list);
            }
        }
        private void Addins_Load(object sender, EventArgs e)
        {
            this.listBoxNav.SelectedIndex = 0;
        }
    }
}
